package net.tv90.bfmccore.slot;

import java.util.HashMap;

public class SideArms {

    public String SideArms = "AIR";
    public String SideArmsAmmo = "AIR";
    public int SideArmsAmmoCount = 0;
    public HashMap<String, String> SideArmsAttachment = null;

    public SideArms(String SideArms, String SideArmsAmmo, int SideArmsAmmoCount, HashMap<String, String> SideArmsAttachment) {
        this.SideArms = SideArms;
        this.SideArmsAmmo = SideArmsAmmo;
        this.SideArmsAmmoCount = SideArmsAmmoCount;
        this.SideArmsAttachment = SideArmsAttachment;
    }

    public SideArms(HashMap<Object, Object> map) {
        this.SideArms = (String) map.get("SideArms");
        this.SideArmsAmmo = (String) map.get("SideArmsAmmo");
        this.SideArmsAmmoCount = (int) map.get("SideArmsAmmoCount");
        this.SideArmsAttachment = (HashMap<String, String>) map.get("SideArmsAttachment");
    }

    public SideArms() {
    }

    //成员变量的getter和setter方法
    public void setSideArms(String SideArms, String SideArmsAmmo, int SideArmsAmmoCount) {
        this.SideArms = SideArms;
        this.SideArmsAmmo = SideArmsAmmo;
        this.SideArmsAmmoCount = SideArmsAmmoCount;
        this.SideArmsAttachment = null;
    }

    public String getSideArms() {
        return this.SideArms;
    }

    public String getSideArmsAmmo() {
        return this.SideArmsAmmo;
    }

    public int getSideArmsAmmoCount() {
        return this.SideArmsAmmoCount;
    }

    public void setSideArmsAttachment(String type, String att) {
        SideArmsAttachment.put(type, att);
    }

    public String getSideArmsAttachment(String type) {
        return SideArmsAttachment.getOrDefault(type, "AIR");
    }

    //序列化
    //SideArms{SideArms:'',SideArmsAmmo:'',SideArmsAmmoCount:'',SideArmsAttachment:''}
    @Override
    public String toString() {
        return "SideArms{SideArms:'" + this.SideArms + "',SideArmsAmmo:'" + this.SideArmsAmmo +
                "',SideArmsAmmoCount:'" + this.SideArmsAmmoCount + "',SideArmsAttachment:'" + this.SideArmsAttachment + "'}";
    }

    public HashMap<Object, Object> toHashMap() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("SideArms", this.SideArms);
        map.put("SideArmsAmmo", this.SideArmsAmmo);
        map.put("SideArmsAmmoCount", this.SideArmsAmmoCount);
        map.put("SideArmsAttachment", this.SideArmsAttachment);
        return map;
    }

    public void setAmmo(String ammo, int amount) {
        this.SideArmsAmmo = ammo;
        this.SideArmsAmmoCount = amount;
    }

    public void setAmmoType(String ammoType) {
        this.SideArmsAmmo = ammoType;
    }
}
